import java.lang.reflect.Array;
import java.util.Arrays;

public class You {
    public void jia(int a,int b){
        int sum = a + b;
        System.out.println("和：" + sum);
    }

    public void jian(int a,int b){
        int jian = a - b;
        System.out.println("减：" + jian);
    }

    public void cheng(int a,int b){
        long cheng = a * b;
        System.out.println("乘：" + cheng);
    }

    public void chu(int a,int b){
        double s = a / b;
        System.out.println("除：" + s);
    }

    public void year(int y){
        if (y % 4 == 0 && y % 100 != 0 || y % 400 ==0){
            System.out.println(y + "是闰年");
        }else {
            System.out.println("不是闰年");
        }
    }

    public void findByName(String name){
        String[] name1 = {"张三","李四","王五"};
        String s = "true";
        for (int i = 0; i < name1.length; i++) {
            if (name1[i] != name){
                s = "ture";
            }else {
                s = "float";
            }
        }
        if (s == "ture"){
            System.out.println(name + "不是我们班的");
        }
        else {
            System.out.println(name + "是我们班的");
        }
    }

    //getMax(),生成一个长度为10的数组，返回这个数组中最大的值
    public int getMax(){
        int[] a = new int[10];
        for (int i = 0; i < a.length - 1; i++) {
            a[i] = (int)(Math.random() *10) + 1;
            System.out.print(a[i] + "\t");
        }
        System.out.println();
        int max1 = a[0];
        for (int i = 1; i < a.length; i++) {
            if (max1 < a[i]){
                max1 = a[i];
            }
        }
        return max1;
    }



    //getStr(),每次调用随机得到剪刀，石头，布
    public String getStr(){
        int a = (int)(Math.random() * 3) + 1;
        String ger = "石头";

        if (a == 1){
            ger = "布";
        }
        if (a == 2){
            ger = "剪刀";
        }
        System.out.println("随机生成的是：" + ger);
        return ger;
    }

    //输入相应的水果得到水果汁
    public String fruit(String name){
        return name + "汁";
    }

    //求1~n的和，n是参数
    public int sum(int n){
        int sum1 = 0;
        for (int i = 1; i < n; i++) {
            sum1 += i;
        }
        return sum1;
    }

    //输入一个十进制的字符串，将这个数转为二进制的字符串
    public String toBinaryString(int num){
        String scaner = "";
        int i = 0;
        while (num != 0){
            int s = num % 2;
            i++;
            if (i == 4) {
                scaner += ",";
                i = 0;
            }
            scaner += "" + s;
            num /= 2;
        }
        return scaner;
    }

    //有如下数组 int[] arr = {1,2,3,5,4,5,2}。
    // 将数组中所有的偶数已数组的形式返回
    public int[] even(){
        int[] arr = {1,2,3,5,4,5,2};
        int[] arr1 = new int[arr.length];
        int j = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % 2 == 0){
                arr1[j] = arr[i];
                j++;
            }
        }
        System.out.println(Arrays.toString(arr1));

        return arr1;
    }
}
